/**
 * 
 */
package br.com.lazyprogrammer.worldsoccermanager.network.builders;

/**
 * 
 * @author Limao Games <br />
 * <b>Email:</b> andreikeda@limaogames.com.br <br />
 * created on: 07/05/2014
 * @version 1.0
 * @see 
 */
public class URLBuilder {
	
	public enum Type {
		Player,
		Stadium,
		Staff,
		Tactics,
		Team;
		
		public static String getType(Type type) {
			switch(type) {
				case Team:
					return "team";
				case Tactics:
					return "tactics";
				case Stadium:
					return "stadium";
				case Staff:
					return "staff";
				case Player:
					return "player";
			}
			
			return "";
		}
	}
	
	private final String URL_GAME	= "/wsm/developer/%s/methods.php";
	private final String URL_HOST	= "http://www.limaogames.com.br/games/webservices";
    private final String URL_NEAR_PLACES = "https://maps.googleapis.com/maps/api/place/search/json?location=%s,%s&radius=%d&sensor=false&key=%s";
    private final String URL_PLACE_DETAIL = "https://maps.googleapis.com/maps/api/place/details/json?reference=%s&sensor=false&key=%s";
	private final String URL_SYSTEM	= "/methods.php";
	
	public URLBuilder() {
		
	}

    public String buildUrlNearPlaces(double latitude, double longitude, int radius, String placesKey) {
        StringBuilder url = new StringBuilder(String.format(URL_NEAR_PLACES, String.valueOf(latitude), String.valueOf(longitude), radius, placesKey));
        return url.toString();
    }

    public String buildUrlPlacesDetail(String reference, String placesKey) {
        StringBuilder url = new StringBuilder(String.format(URL_PLACE_DETAIL, reference, placesKey));
        return url.toString();
    }

    public String buildUrlGame(Type type) {
		StringBuilder url	= new StringBuilder(URL_HOST);
		url.append(String.format(URL_GAME, Type.getType(type)));
		return url.toString();
	}
	
	public String buildUrlSystem() {
		StringBuilder url	= new StringBuilder(URL_HOST);
		url.append(URL_SYSTEM);
		return url.toString();
	}

}
